package com.jiaodian.auth.controller;

import com.jiaodian.auth.service.IRegisterService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;
import result.Result;
import vo.EmailRegisterVo;

/**
 * @Author:princess
 * @Date:2024/10/8-10-08-20:45
 */
@RestController
@RequestMapping("/auth/register")
@Tag(name = "注册服务",description = "各种注册服务")
@RefreshScope
public class RegisterController {

    @Autowired
    private IRegisterService registerService;

    // 找得到返回数据，找不到返回null
    @Value("${spring.application.name}")
    private String name;

    /**
     * 测试配置中心
     */
    @GetMapping("/test")
    @Operation(summary = "测试配置中心",description = "测试配置中心")
    public Result test(){
        return Result.success(name);
    }

    /**
     * 邮箱注册
     */
    @PostMapping("/v1/email")
    @Operation(summary = "邮箱注册v1")
    public Result emailRegister(@RequestBody EmailRegisterVo emailRegisterVo){
        registerService.sendVerifyEmail(emailRegisterVo.getEmail());
        return Result.success("注册成功");
    }

    /**
     * 校验用户邮箱是否正确
     * @return
     */
    @GetMapping("/v1/check")
    @Operation(summary = "校验用户邮箱是否正确")
    public Result emailCheck(){

        return Result.success("注册成功");
    }
}
